//
const {Container, Maybe} =require('./support')
const fp=require('loadsh/fp')

// 问题1

let maybe=Maybe.of([5,6,1]);
let ex1=(num)=>{
 return maybe.map(fp.map(fp.add(num)))
}
ex1(1)

// 问题2

let xs=Container.of(['do','ra','mi','fa','so','la','ti','do']);

let ex2=()=>{
  return xs._value
}
fp.first(ex2())

//问题 3

let sageProp=fp.curry(function(x,o){
   return Maybe.of(o[x])
})
let user={id:2,name:'Albert'};
let ex3=()=>{
   return fp.first(sageProp('name',user)._value)
}
ex3()

//问题 4

// let ex4=function(n){
//   if(n){
//     return parseInt(n)
//   }
// }

let ex4=(n)=>{
  let maybe=Maybe.of(n);
  return  maybe.map(parseInt(n)._value)
}
ex4()
